*************************************************************************************************
********************************* Molina-Garzon, Grillos, Zarychta and Andersson  *********************
***************************************  Public Good Game **************************************
*************************************************************************************************

** Table 3. Results with clustered standard errors by individual
/* The following commands construct table 3. Names of the variables are adjusted manually 
*/

global yourlocation "/Users/adrianamolina/Documents/CU-Boulder/2017-Fall/QualifierP/Data_Analysis"
use `"${yourlocation}/publicgoodgame_dataAug27.dta"'

global xlistfinal decentralized i.p_type communication round lag_groupcontribution num_players knownpeople Q2_female Q1_Edad Q2_Educacion Q3_YrsSalud Q5_Trust1Base
global xlistfinal2 i.decentralized##i.communication i.p_type round lag_groupcontribution num_players knownpeople Q2_female Q1_Edad Q2_Educacion Q3_YrsSalud Q5_Trust1Base

quiet reg contribution $xlistfinal [pweight = weights_games_full_scaled], vce(cluster publicid)
quiet estat ic
mat es_ic = r(S)
local AIC : display %4.1f es_ic[1,5]
outreg2 using `"${yourlocation}/table3.doc"', ctitle(Main Model) addstat(AIC, `AIC') replace
quiet reg contribution $xlistfinal2 [pweight = weights_games_full_scaled], vce(cluster publicid)
quiet estat ic
mat es_ic = r(S)
local AIC : display %4.1f es_ic[1,5]
outreg2 using `"${yourlocation}/table3.doc"', ctitle(Model with Communication Interaction) addstat(AIC, `AIC') append


** Figure 3. Decentralization is Associated with Increased Cooperation by Public Servants when they are able to Communicate with Each Other

twoway (rcap highconf_ols_2 lowconf_ols_2 round if decentralized==1, lcolor(black) legend(label(1 "CI"))) (line outcome_ols_2 round if decentralized==1, xlabel(1(1)10) lpattern(solid) lcolor(black) legend(label(2 "Decentralized municipalities"))) ///
(rcap highconf_ols_2 lowconf_ols_2 round if decentralized==0, lcolor(gray) legend(label(3 "CI"))) (line outcome_ols_2 round if decentralized==0, lpattern(dash) lcolor(gray) legend(label(4 "Centrally-admin. municipalities"))), ///
graphregion(fcolor(white) ifcolor(white))

graph save Graph `"${yourlocation}/Figure3_cooperation by admin type.gph"'


***** Supplementary appendix

*Table SA3. Main cooperation model with reduced sample weights
quiet metobit contribution $xlistfinal [pweight = weights_games_reduced_scaled] || publicid_muni: || publicid:, ul(10) ll(0)
quiet estat ic
mat es_ic = r(S)
local AIC : display %4.1f es_ic[1,5]
outreg2 using `"${yourlocation}/tableSA3.doc"', ctitle(Model A) addstat(AIC, `AIC') replace 
quiet metobit contribution $xlistfinal2 [pweight = weights_games_reduced_scaled] || publicid_muni: || publicid:, ul(10) ll(0)
quiet estat ic
mat es_ic = r(S)
local AIC : display %4.1f es_ic[1,5]
outreg2 using `"${yourlocation}/tableSA3.doc"', ctitle(Model B) addstat(AIC, `AIC') append
quiet reg contribution $xlistfinal [pweight = weights_games_reduced_scaled], vce(cluster publicid)
quiet estat ic
mat es_ic = r(S)
local AIC : display %4.1f es_ic[1,5]
outreg2 using `"${yourlocation}/tableSA3.doc"', ctitle(Model C) addstat(AIC, `AIC') append
quiet reg contribution $xlistfinal2 [pweight = weights_games_reduced_scaled], vce(cluster publicid)
quiet estat ic
mat es_ic = r(S)
local AIC : display %4.1f es_ic[1,5]
outreg2 using `"${yourlocation}/tableSA3.doc"', ctitle(Model D) addstat(AIC, `AIC') append


*Table SA5. Alternative cooperation model, Multilevel Tobit specification

quiet metobit contribution $xlistfinal [pweight = weights_games_full_scaled] || publicid_muni: || publicid:, ul(10) ll(0)
quiet estat ic
mat es_ic = r(S)
local AIC : display %4.1f es_ic[1,5]
outreg2 using `"${yourlocation}/tableSA5.doc"', ctitle(Model A) addstat(AIC, `AIC') replace 
quiet metobit contribution $xlistfinal2 [pweight = weights_games_full_scaled] || publicid_muni: || publicid:, ul(10) ll(0)
quiet estat ic
mat es_ic = r(S)
local AIC : display %4.1f es_ic[1,5]
outreg2 using `"${yourlocation}/tableSA5.doc"', ctitle(Model B) addstat(AIC, `AIC') append


* Figure SA3: Raw data distribution for public good game results
sort decentralized round
twoway (line averagecont round if decentralized==1, ylabel(0(1)10) xlabel(1(1)10) lcolor(black) lpattern(solid) legend(label(1 "Decentralized municipalities"))) (line averagecont round if decentralized==0, lcolor(gray) lpattern(dash) legend(label(2 "Centrally-admin. municipalities"))), /// 
graphregion(fcolor(white) ifcolor(white))

graph save Graph `"${yourlocation}/FigureSA3.gph"'

* SA 9- Table SA 17. Analysis by types of intermediary organizations

global xlistfinal4 i.dec_orgtype i.p_type communication round lag_groupcontribution num_players knownpeople Q2_female Q1_Edad Q2_Educacion Q3_YrsSalud Q5_Trust1Base
global xlistfinal5 i.dec_orgtype##i.communication i.p_type round lag_groupcontribution num_players knownpeople Q2_female Q1_Edad Q2_Educacion Q3_YrsSalud Q5_Trust1Base

quiet metobit contribution $xlistfinal4 [pweight = weights_games_full_scaled] || publicid_muni: || publicid:, ul(10) ll(0)
quiet estat ic
mat es_ic = r(S)
local AIC : display %4.1f es_ic[1,5]
outreg2 using `"${yourlocation}/table-SA17.doc"', ctitle(Model A) addstat(AIC, `AIC') replace 
quiet metobit contribution $xlistfinal5 [pweight = weights_games_full_scaled] || publicid_muni: || publicid:, ul(10) ll(0)
quiet estat ic
mat es_ic = r(S)
local AIC : display %4.1f es_ic[1,5]
outreg2 using `"${yourlocation}/table-SA17.doc"', ctitle(Model B) addstat(AIC, `AIC') append
quiet reg contribution $xlistfinal4 [pweight = weights_games_full_scaled], vce(cluster publicid)
quiet estat ic
mat es_ic = r(S)
local AIC : display %4.1f es_ic[1,5]
outreg2 using `"${yourlocation}/table-SA17.doc"', ctitle(Model C) addstat(AIC, `AIC') append
quiet reg contribution $xlistfinal5 [pweight = weights_games_full_scaled], vce(cluster publicid)
quiet estat ic
mat es_ic = r(S)
local AIC : display %4.1f es_ic[1,5]
outreg2 using `"${yourlocation}/table-SA17.doc"', ctitle(Model D) addstat(AIC, `AIC') append


* Table SA 18. Regression analysis explaining perceived improvements in health outcomes
* This table requires a different dataset

clear

global yourlocation "/Users/adrianamolina/Documents/CU-Boulder/2017-Fall/QualifierP/Data_Analysis"
use `"${yourlocation}/healthperception_Aug2020"'

quiet reg HealthChange_Mun contribution [pweight = weights_games_full_scaled]
quiet estat ic
mat es_ic = r(S)
local AIC : display %4.1f es_ic[1,5]
outreg2 using `"${yourlocation}/tableSA18.doc"', ctitle(Model A) addstat(AIC, `AIC') replace 
quiet reg HealthChange_Mun decentralized [pweight = weights_games_full_scaled]
quiet estat ic
mat es_ic = r(S)
local AIC : display %4.1f es_ic[1,5]
outreg2 using `"${yourlocation}/tableSA18.doc"', ctitle(Model B) addstat(AIC, `AIC') append 
quiet reg HealthChange_Mun contribution decentralized [pweight = weights_games_full_scaled]
quiet estat ic
mat es_ic = r(S)
local AIC : display %4.1f es_ic[1,5]
outreg2 using `"${yourlocation}/tableSA18.doc"', ctitle(Model C) addstat(AIC, `AIC') append 

* Figure SA 6. Contribution to the public good game and perception of change in the health provision during the past five years 

set scheme s1mono
twoway (scatter HealthChange_Mun0 contribution) (scatter HealthChange_Mun1 contribution) ///
	(lfit HealthChange_Mun contribution), ///
	ytitle(Health change in last 5 years) ///
	legen(order(1 "Centralized admin." 2 "Decentralized admin." 3 "Fit line"))


graph save Graph `"${yourlocation}/FigureSA6.gph"'



